<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
[#include "/include/main.ftl"]
[#include "/include/zTree.ftl"]
[#include "/include/popdialog.ftl"]
[#include "/include/flexigrid.ftl"]
    <script>
        var dirSn = '';
        var setting = {
            async : true,
            asyncUrl : "/nxl/manager/dirList",
            asyncParam : ["sn"],
            treeNodeKey : "sn",
            treeNodeParentKey : "parentSn",
            showLine : true,
            expandSpeed:"",
            callback : {
                click: zTreeOnClick
            }
        };

        function zTreeOnClick(event, treeId, treeNode) {
            dirSn = treeNode.sn;
            $(".contentlist").flexOptions({url : '/nxl/manager/contentList/' + dirSn , page: 1});
            $(".contentlist").flexReload();

        }

        var zTree;
        $(document).ready(function() {
            zTree = $("#tree").zTree(setting);
        });


        function refreshDir () {
            var treeNode = zTree.getSelectedNode();
            if (!treeNode) {
                return;
            }
            zTree.reAsyncChildNodes(treeNode, "refresh")
        }


        function editDir1(sn) {
            if (dirSn == '') {
                alert('请选择目录 ');
                return
            }
            popDialog("editDir", "编辑目录",
                    "/nxl/manager/editDir/" + sn,
                    refreshDir, 400, 400);
        }

        function newSubDir1(sn) {
            if (dirSn == '') {
                alert('请选择目录 ');
                return
            }
            popDialog("newSubDir", "新建目录",
                    "/nxl/manager/newDir/" + sn,
                    function (data) {
                        if (data =='ok') {
                            zTree.getSelectedNode().isParent = true;
                            refreshDir();
                        }
                    }, 400, 400);
        }

        function delDir1(sn) {
            if (dirSn == '') {
                alert('请选择目录 ');
            } else {
                if (confirm('确定要删除本目录？')) {
			        $.post('/nxl/manager/delDir/' + sn, null,
					function(data){
						if (data == 'ok') {
                            dirSn = zTree.getSelectedNode().parentNode.sn;
                            zTree.selectNode(zTree.getSelectedNode().parentNode);
							refreshDir();
						} else {
                            alert(data);
                        }
						},
					"json");
			    }
            }
        }

        var rc = function refreshContent() {
            $(".contentlist").flexOptions({url : '/nxl/manager/contentList/' + dirSn , page: 1});
            $(".contentlist").flexReload();
        };

        function editContent(sn) {
            popDialog("editContent", "编辑文章",
                    "/nxl/manager/editContent/" + sn,
                    rc, 800, 800);
        }

        function delContent(sn) {
			if (confirm('确定要删除本文章？')) {
			    $.post('/nxl/manager/delContent/' + sn, null,
                        function(data) {
                            if (data == 'ok') {
                                rc();
                            } else {
                                alert(data);
                            }
                        }
                        , "json");
			}
        }

        function newContent1(sn) {
            if (dirSn == '') {
                alert('请选择目录 ');
                return
            }
            popDialog("newContent", "新建文章",
                    "/nxl/manager/newContent/" + sn,
                    rc, 800, 800);
        }
    </script>

</head>
<body>

<div class="ui-widget page">
[#include '/top.ftl']

    <div class="content">
        <div style="width:200px;height:600px;float:left; position:relative;">
            <ul id="tree" class="tree" style="width:200px; overflow:auto;"></ul>
        </div>
        <div style="width:800px;height:600px;float:left; position:relative;">
            <form id="form1" name="form1" method="post" action="">
                <input type="button" name="button" id="button" value="新建子目录" onClick="newSubDir1(dirSn);"/>
                <input type="button" name="button2" id="button2" value="修改目录" onclick="editDir1(dirSn);"/>
                <input type="button" name="button3" id="button3" value="删除目录" onclick="delDir1(dirSn);"/>
                |
                <input type="button" name="btn" id="btn" value="新建文章" onClick="newContent1(dirSn);"/>
        <table class="contentlist" style="display: none"></table>
                <script>

                    $(".contentlist").flexigrid({
                        url : '/nxl/manager/contentList/xx',
                        dataType : 'json',
                        colModel : [
                            {display : 'sn', name : 'sn', width : 200, sortable : true, align : 'left', hide:true},
                            {display : '文章标题', name : 'title', width : 380, sortable : true, align : 'left'},
                            {display : '创建时间', name : 'createTime', width : 100, sortable : true, align : 'left'},
                            {display : '排序', name : 'dispOrder', width : 35, sortable : true, align : 'left'},
                            {display : '操作', name : 'op', width : 35, sortable : true, align : 'left'}
                        ],
                        sortname : "createTime",
                        sortorder : "desc",
                        usepager : true,
                        title : '文章列表',
                        useRp : true,
                        rp : 15,
                        showTableToggleBtn : true,
                        singleSelect : true,
                        width : 642,
                        height : 500,
                        onRowDblclick : function(rowData) {
                            editContent($(rowData).data("sn").toString());
                        }

                    });

                </script>
            </form>
        </div>
    </div>

[#include '/bottom.ftl']
</div>
</body>
</html>